#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    map<int, int> Map;
    int Max = 1;
    while (n--) {
        int k;
        cin >> k;
        while (k--) {
            int t;
            cin >> t;
            if (Map.find(t) == Map.end()) {
                Map.insert(pair<int, int>(t, 1));
            } else {
                Map[t]++;
                Max = max(Max, Map[t]);
            }
        }
    }
    for (auto it = Map.rbegin(); it != Map.rend(); it++) {
        if (it->second == Max) {
            cout << it->first << " " << it->second << endl;
            break;
        }
        
    }
    
    
    return 0;
}